package logic

import (
	"context"

	"game/rpc/gamerpc/game"
	"game/rpc/gamerpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic {
	return &DeleteUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteUserLogic) DeleteUser(in *game.DeleteUserRequest) (*game.DeleteUserResponse, error) {
	// todo: add your logic here and delete this line
	// 根据用户ID删除用户
	err := l.svcCtx.UsersModel.Delete(l.ctx, int64(in.Id))
	if err != nil {
		return nil, err
	}

	// 返回成功响应
	return &game.DeleteUserResponse{
		Success: true,
	}, nil
}
